'use strict';

const BaseController = require('../base');
const { Op } = require('sequelize');
class BannerController extends BaseController {
  static get serviceName() {
    return 'business.ticketLine';
  }
  afterFormatQuery(where, query) {
    if (query.keyword) {
      // 使用或的关系处理以上like
      where[Op.or] = [
        { title: { [Op.like]: `%${query.keyword}%` } },
        { description: { [Op.like]: `%${query.keyword}%` } },
        { content: { [Op.like]: `%${query.keyword}%` } },
        { tags: { [Op.like]: `%${query.keyword}%` } },
        { tags2: { [Op.like]: `%${query.keyword}%` } },
        { tags3: { [Op.like]: `%${query.keyword}%` } },
      ]
    } else {
      delete where.keyword
    }
    return where
  }
}

module.exports = BannerController;
